package com.sicheng.lc.周赛.分类.图论;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/23 10:07
 */
public class 找出输掉零场或一场比赛的玩家 {
    //https://leetcode.cn/problems/find-players-with-zero-or-one-losses/
    public List<List<Integer>> findWinners(int[][] matches) {
        int[] st = new int[(int) 1e5 + 1];

        Arrays.fill(st, -1);
        for (int[] match : matches) {
            if (st[match[0]] == -1) {
                st[match[0]] = 0;
            }
            if (st[match[1]] == -1) {
                st[match[1]] = 0;
            }
            st[match[1]]++;
        }
        ArrayList<Integer> l0 = new ArrayList<>();
        ArrayList<Integer> l1 = new ArrayList<>();
        for (int i = 0; i < st.length; i++) {
            if (st[i] == 0) {
                l0.add(i);
            } else if (st[i] == 1) {
                l1.add(i);
            }
        }
        ArrayList<List<Integer>> res = new ArrayList<>();
        res.add(l0);
        res.add(l1);
        return res;
    }
}
